/*
 * HttpServer.h
 *
 *  Created on: 2021年4月6日
 *      Author: san
 */

#ifndef HTTPSERVER_H_
#define HTTPSERVER_H_

#include <memory>
#include "Channel.h"
#include "EventLoop.h"
#include "EventLoopThreadPool.h"

namespace san {

class HttpServer {
public:
	HttpServer(EventLoop *loop, int threadNum, int port);
	~HttpServer();

	EventLoop *getLoop() const { return loop_; }
	void start();
	void handNewConn();
	void handThisConn() {loop_->updatePoller(acceptChannel_);}

private:
	EventLoop *loop_;
	int threadNum_;
	std::unique_ptr<EventLoopThreadPool> eventLoopTHreadPoll_;
	bool started_;
	std::shared_ptr<Channel> acceptChannel_;
	int port_;
	int listenFd_;
	static const int MAXFDS = 100000;

};

} /* namespace san */

#endif /* HTTPSERVER_H_ */
